--
-- Author: yawei.zhu
-- Date: 2018-07-06 16:02:15
--

local PvpChampionThroneTeam = class("PvpChampionThroneTeam")

function PvpChampionThroneTeam:ctor(info)
	if info then
		self:read(info)
	end
end

function PvpChampionThroneTeam:read(info, isLessData)
	self.teamId = info.TeamID
	if not isLessData then
		self.name = info.Name
		self.icon = info.Icon
	end
	self.members = {}
	-- dump(info.members)
	print("teamId = ", self.teamId)

	for _, data in ipairs(info.members) do
		local value = {}
		value.uid = data.uid
		value.baseInfo = UserBaseInfo.new(data.baseinfo)
		table.insert(self.members, value)

		print(value.baseInfo.name, value.uid, value.baseInfo.combatPower)
	end
end

function PvpChampionThroneTeam:test()
	local info = {}
	info.TeamID = 10
	info.Name = "a123123"
	info.Icon = 1231

	local members = {}
	for i = 1, 3 do
		local value = {}
		value.uid = 1123
		value.baseinfo = UD:getAvatarParams()
		table.insert(members, value)
	end
	info.members = members
	self:read(info)
end

function PvpChampionThroneTeam:getUserBaseInfo(i)
	local member = self.members[i]
	if member then return member.baseInfo end
	return nil
end

function PvpChampionThroneTeam:getMemCount()
	return #self.members
end

function PvpChampionThroneTeam:isMyTeamMember(uid)
	for _, member in ipairs(self.members) do
		if member.uid == uid then
			return true
		end
	end
	return false
end

return PvpChampionThroneTeam

